﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;

namespace Orderr
{
    [Serializable]
    public class OrderDetails
    {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
        public int OrderDetailsID { get; set; }
//        public int OrderID { get; set; }
//        public Order Order { get; set; }
       public int GoodID { get; set; }
        [ForeignKey("GoodID")]
        public virtual Good Good  { get; set; }
        public int Nums {get; set; }
        public int Amo {get; set;}
        public String detail
        {
            get { return ToString(); }
        }

        public OrderDetails(int ID, Good goo, int num)
        {
            OrderDetailsID = ID; GoodID = goo.GoodID; Nums = num; Amo = goo.Price * Nums;
        }
        public OrderDetails()
        {

        }
        public override bool Equals(object obj)
        {
            OrderDetails ob = obj as OrderDetails;
            return Good == ob.Good && Nums == ob.Nums;
        }
        public override int GetHashCode()
        {
            return Good.GetHashCode() + Nums;
        }
        public override string ToString()
        {
            return Good.ToString() + "共" + Nums + "件\n";
        }

    }
}
